//
//  rowTableViewController.m
//  11210
//
//  Created by student on 16/3/4.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "rowTableViewController.h"

@interface rowTableViewController ()
@property(nonatomic,strong)NSArray *list;
@end

@implementation rowTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.list = @[@"C3PO", @"Tik-Tok", @"Robby", @"Rosie", @"Uniblab",
                  @"Bender", @"Marvin", @"Lt. Commander Data",
                  @"Evil Brother Lore", @"Optimus Prime", @"Tobor", @"HAL",
                  @"Orgasmatron",@"C3PO", @"Tik-Tok", @"Robby", @"Rosie", @"Uniblab",
                  @"Bender", @"Marvin", @"Lt. Commander Data",
                  @"Evil Brother Lore", @"Optimus Prime", @"Tobor", @"HAL",
                  @"Orgasmatron"];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.list.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text=self.list[indexPath.row];
    if(cell.accessoryView==nil)
    {
        UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame=CGRectMake(0, 0, 50, 27);
        [btn setBackgroundImage:[UIImage imageNamed:@"button_up"] forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:@"button_down"] forState:UIControlStateHighlighted];
        [btn setTitle:@"按我" forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(btnpressed:) forControlEvents:UIControlEventTouchUpInside];
        cell.accessoryView=btn;
    }
    UIButton *btn=cell.accessoryView;
    btn.tag=indexPath.row;

    
    return cell;
}
-(void)btnpressed:(UIButton *)btn
{
    NSLog(@"选中了%@",self.list[btn.tag]);
}


@end
